<%= stylesheet_link_tag("calendar") %>

<%= javascript_include_tag "calendar" %>
<h1>Listing tasks</h1>

<%= link_to "< previous", {:controler => :tasks, :action => :index, :date => @startdate-7} %>
&nbsp;|&nbsp;
<%= link_to "today", {:controler => :tasks, :action => :index, :date => Date.today} %>
&nbsp;|&nbsp;
<%= link_to "next >", {:controler => :tasks, :action => :index, :date => @startdate+7} %>
<table>
  <tr>
	<th></th>
	<% current_week.each do |day| %>
		<th><%= day %></th>
	<% end %>
  </tr>
  
  <% current = @startdate.at_beginning_of_week.to_datetime %>
  <% format_tasks.each do |hours| %>
    <tr>
		<td><%= "#{current.hour}h"%></td>
		<% hours.each do |day| %>
			<td id="<%= current.to_time.to_i %>" >
					<% day.each do |task| %>
						<p id="<%= task.id %>">
							<%= link_to task.label, task %>
						</p>
					<% end %>
			</td>
			<% current = current+1.day %>
		<% end %>
    </tr>
	<% current = current-7.day %>
	<% current = current+1.hour %>
  <% end %>
</table>

<br />

<%= link_to 'New task', new_task_path %>